#ifndef _SERIALDATA_H
#define _SERIALDATA_H

#include <iostream>

template <typename T>
struct SerialData
{
	SerialData() : length( sizeof(T) )
	{
		/* nothing */
	}

	const int length;

	union
	{
		T		data;
		char	buffer[sizeof(T)];
	} ;

	void Copy(char *dest)
	{
		for( int i = 0; i < (length - 1); ++i )
		{
			dest[i] = buffer[i];
		}
		//std::copy(buffer[0], buffer[length - 1], dest);
	}
 
	void Set(char *source)
	{
		for( int i = 0; i < (length - 1); ++i )
		{
			buffer[i] = source[i];
		}
		//std::copy(source[0], source[length - 1], buffer);
	}

	int GetSize()
	{
		return sizeof(T);
	}
};

#endif